<template>
  <div>
    <!--导航栏-->
    <Header></Header>
    <!--内容-->
    <div class="user_container">
      <div class="user_box">
        <div class="user_title">
          <div class="general-info-t">
            <div class="user_img">
              <img src="../assets/user_logo.jpg" />
            </div>
            <div class="general-info-t-info">
              <div class="profile-name-info">
                <span>{{ d.idCard }}</span>
              </div>
              <div class="profile-age">
                <img src="../assets/agelog.gif" />
                <span>码龄84天</span>
              </div>
            </div>
          </div>
          <div data-v-60b18741="" class="base-info-head">基本信息</div>
        </div>
        <div class="user_form">
          <div class="base-info-content">
            <div class="base-info-content-show">
              <el-form label-width="100px">
                <el-form-item label="用户ID:">
                  <span>{{ d.id }}</span>
                </el-form-item>
                <el-form-item  label="用户昵称:">
                  <el-input v-model="d.idCard"></el-input>
                </el-form-item>
                <el-form-item label="性别:">
                  <el-radio v-model="d.sex" :label="1">男</el-radio>
                  <el-radio v-model="d.sex" :label="2">女</el-radio>
                </el-form-item>
                <el-form-item label="所在地区:">
                  <el-input v-model="d.address"></el-input>
                </el-form-item>
                <el-form-item label="个人简介:">
                  <el-input v-model="d.memo" type="textarea" :rows="2" placeholder="这个人很懒，没有任何描述"></el-input>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="updateUser()">提交</el-button>
                  <a href="login">
                  <el-button @click="outlogin()">退出登录</el-button>
                  </a>
                </el-form-item>
              </el-form>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!--footer -->
    <footer>
    </footer>
  </div>
</template>

<script>
  import Header from '../components/Header';
  import Footer from '../components/Footer';
  export default {
    name: 'Vip',
    components: {
      Header,
      Footer
    },
    data() {
      return {
        d: {}
      }
    },
    methods: {
      /*单个id查询用户*/
      findUserById(id) {
        this.updateFormVisible = true
        let _this = this
        console.log(id)
        this.$axios.get("http://localhost:8087/user/getUserById/" + id).then(function(res) {
          _this.d = res.data
          console.log(res.data)
        }).catch(function(err) {
          alert('请登陆哦~')
        })
      },
      /*修改用户信息*/
      updateUser() {
        let _this = this;
        // 发送axios请求，根据查询一个
        this.$axios
          .post('http://localhost:8087/user/updateUser', _this.d)
          .then(function(res) {
            alert('用户信息修改成功!');
            _this.updateFormVisible = false;
            _this.findAll();
          })
          .catch(function(err) {});
      },
      /*退出登录*/
      outlogin(){
        removeItem('id')
      }
    },
    created() {
      this.findUserById(localStorage.getItem("id"))
    }
  }
</script>

<style scoped>
  .user_container {
    position: relative;
    width: auto;
    min-width: 896px;
    min-height: 800px;
    background: transparent;
    margin: 10px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .user_box {
    min-height: 800px;
    -webkit-font-smoothing: antialiased;
    min-width: 1000px;
    -ms-flex-line-pack: justify;
    align-content: space-between;
  }

  .user_title {
    min-height: 208px;
    box-shadow: 2px 2px 10px #d4d4d4;
  }

  .user_form {
    margin-top: 10px;
    min-height: 600px;
    box-shadow: 2px 2px 10px #d4d4d4;
  }

  .general-info-t {
    padding: 24px 0 40px 24px;
    position: relative;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-shadow: 0 1px 8px 0 rgba(0, 0, 0, .04);
    box-shadow: 0 1px 8px 0 rgba(0, 0, 0, .04);
  }

  .base-info-head {
    height: 48px;
    line-height: 48px;
    font-size: 18px;
    font-weight: 600;
    color: #2e2e2e;
    padding-left: 16px;
    border-bottom: 1px solid #f0f0f2;
  }

  .user_img {
    -ms-flex-negative: 0;
    flex-shrink: 0;
    position: relative;
    width: 96px;
    height: 96px;
    margin-right: 16px;
    -webkit-box-shadow: 0 0 10px 2px rgba(0, 0, 0, .06);
    box-shadow: 0 0 10px 2px rgba(0, 0, 0, .06);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
  }

  .general-info-t .user_img img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
  }

  .general-info-t-info {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
  }

  .profile-name-info {
    margin-bottom: 16px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
  }

  .profile-age {
    display: flex;
  }

  .profile-age span {
    color: #999aaa;
    margin-right: 88px;
  }

  .profile-age img {
    width: 22px;
    height: 22px;
    margin-right: 10px;
    display: block;
  }

  .profile-name-info span {
    color: #222226;
    font-weight: 500;
    line-height: 24px;
    font-size: 20px;
    margin-right: 16px;
  }

  .base-info-content {
    padding: 16px;
  }

  .base-info-content-show {
    padding: 16px 58px 16px 0;
    position: relative;
  }
</style>
